#!/usr/bin/env python
# coding: utf-8

import requests
import time
import random
import socket
import psutil

hostname = socket.gethostname()
while True:
	cpu = psutil.cpu_percent()
	#value = random.randint(10, 100)
	value = int(cpu)
	print cpu
	key = time.strftime("%H:%M:%S")
	#key = int(time.time())
	params = { "name": hostname + "/python/randint", "key":key, "value":value}
	r = requests.post("http://localhost:8033/api/v1/add", data=params)
	print r.text
	time.sleep(1)
